//绘制类，用于绘画背景，字母图片
var letter;//字母类实例
function draw(){
	this.x;//画布背景坐标
	this.y;
	this.ctx;//画笔
	this.bgPic;//背景
	this.le;//显示数组，保存字母对象实例
}
//初始化
draw.prototype.init=function(){
	this.le=[];
	for(var i=0;i<5;i++){//屏幕上有8个字母
		newLe();
		this.le.push(letter);//将字母对象加入数组
	}
	this.x=0;
	this.y=0;
	this.bgPic=new Image();//图片类型
	this.bgPic.src='images/bg2.png';
}
draw.prototype.ImgDraw=function(){
	//绘制图片
	this.ctx.drawImage(this.bgPic,this.x,this.y,632,472);//背景

	for(var i=0;i<this.le.length;i++){
		this.le[i].leBackground();//画出字母
		if(this.le[i].Ay>=432){
			this.born(i);
		}
	}
}
//生成字母
draw.prototype.born=function(i){
	this.le[i].aLive=false;//消失
	this.le[i].letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
				'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
	this.le[i].ctx=this.ctx;
	this.le[i].x=Math.floor(Math.random()*400)+80;;
	this.le[i].y=0;
	this.le[i].Ax=this.le[i].x-15;//注意这里苹果坐标
	this.le[i].Ay=this.le[i].y-40;
	this.le[i].aLive=true;//默认激活
	this.le[i].spd=Math.random()*0.017+0.003;//速度区间在[0.01-0.015)
	this.le[i].lett=letter.letters[Math.floor(Math.random()*48)];//随机挑选字母
	this.le[i].lePic=new Image();//图片类型
	this.le[i].lePic.src='images/苹果[图形].png';
	this.le[i].fColor=this.le[i].fColor;
	var le_i=this.le[i];//保存第i个对象初始属性
	this.le.splice(i,1,le_i);//删除并添加字母对象
}
//Letters对象实例函数
function newLe(){
		letter=new Letters();//new一个对象
		letter.letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
				'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
		letter.ctx=this.ctx;
		letter.x=Math.floor(Math.random()*400)+80;
		letter.y=0;
		letter.Ax=letter.x-15;//苹果坐标是相对坐标
		letter.Ay=letter.y-40;
		letter.aLive=true;//默认激活
		letter.spd=Math.random()*0.017+0.003;//速度区间在[0.01-0.015)
		letter.lett=letter.letters[Math.floor(Math.random()*48)];//随机挑选字母
		letter.lePic=new Image();//图片类型
		letter.lePic.src='images/苹果[图形].png';
		letter.fColor='yellow';
		letter.leBackground();
}